package band.wukong.practice.urule.sample1;

import com.bstek.urule.model.ExposeAction;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 专用动作库（普通）
 *
 * @author wukong(wukonggg@139.com)
 */
public class SpecialActionsTest {

    @ExposeAction("eval")
    public boolean eval(String name) {
        if (null == name) {
            return false;
        } else if ("eval".equals(name)) {
            return true;
        }
        return false;
    }

    @ExposeAction("加法ADD")
    public int add(int a, int b) {
        return a + b;
    }

    public int multiply(int a, int b) {
        return  a + b;
    }

    @ExposeAction("打印")
    public void print(String name, Date birth) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd");
        if (null != birth) {
            System.out.println(name + "'s birthday is " + sdf.format(birth) + ".");
        } else {
            System.out.println("Hello " + name + "!");
        }
    }
}
